package com.xiaoyao.myframeapp.utils.RichScan;

import android.graphics.Bitmap;
import android.text.TextUtils;

import com.uuzuche.lib_zxing.activity.CodeUtils;
import com.xiaoyao.myframeapp.FrameApplication;

/**
 * @Author xiaoyao
 * @Email xiao80206040@qq.com
 * @Explain TODO 创建二维码逻辑
 * @Created by Administrator on 2017/10/8 0008 16:33
 */
public class RichScanCreateLogic {

    /**
     * TODO 创建二维码逻辑
     *
     * @param type
     * @param s
     */
    public static RichScanBean RichScan_Dispose(String type, String s) {
        if (TextUtils.isEmpty(type)) {
            return null;
        }
        RichScanBean richScanBean = new RichScanBean();
        richScanBean.setWoyouzhijia_type(type);

        int t = Integer.valueOf(type);
        switch (t) {
            case 0:
                break;
            case 1:
                richScanBean.setUrl(s);
                break;
        }
        return richScanBean;

//        //TODO 调用生成二维码方法
//        RichScanDisposeBitmap(WoxingApplication.toJson(richScanBean));

    }

    /**
     * 生成二维码
     *
     * @param textContent
     * @return
     */
    public static Bitmap RichScanDisposeBitmap(String textContent) {
//        Bitmap bitmap = CodeUtils.createImage(textContent, 400, 400, null);
//
//        return bitmap;
        return CodeUtils.createImage(textContent, 400, 400, null);
    }

    /**
     * 生成二维码 快速方法
     *
     * @param type
     * @param s
     * @return
     */
    public static Bitmap RichScanGetBitmap(String type, String s) {
        String rs = FrameApplication.toJson(RichScan_Dispose(type, s));

        if (TextUtils.isEmpty(rs)) {
            return null;
        }
//        Bitmap bitmap =RichScanDisposeBitmap(rs);
        return RichScanDisposeBitmap(rs);
//        return bitmap;
    }

}
